package com.glodon.controller;

import com.glodon.service.UserService;
import com.glodon.vo.Good;
import com.glodon.vo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by wanghy-h on 2017-10-25.
 */
@RestController
@RequestMapping(value = "/test/*") //访问的url地址前缀，可以不写，写了就必须在方法url前面先加上class url 进行区分控制器
public class TestController {

    @Autowired
    private UserService userService;

    @RequestMapping(value = "returnSuccess")
    public Map testUrl(){
        Map map = new HashMap();
        map.put("1","a");
        map.put("2","b");
        map.put("3","c");
        return map;
    }
    @RequestMapping("/login")
    public Map showPerson(String userName, String password){
        System.out.print(userName+password);
        Map map = new HashMap();
        map.put("1","a");
        map.put("2","b");
        map.put("3","c");
        return map;
    }

    @RequestMapping(value = "getGoods")
    public List getGoods(){
        List list = new ArrayList();
        Good good = new Good(1,"a","123","aaa");
        Good good2 = new Good(2,"b","123","bbb");
        Good good3 = new Good(3,"c","123","ccc");
        Good good4 = new Good(4,"d","123","ddd");
        list.add(good);
        list.add(good2);
        list.add(good3);
        list.add(good4);
        return list;
    }

    @RequestMapping(value = "getData")
    public List<User> getData(){
        List<User>  list = userService.selectAllUser();
        return list;
    }
}
